/**
 * Created by liyu on 2018/3/1.
 */
// 授权登录
export default  login= (userType)=> {
  if (!window.localStorage.openid) {
    let jsonValue = JSON.stringify({
      'c': '10005',
      'p': {
        'userType': userType,
        'openid': window.localStorage.openid
//            "access_token": window.localStorage.access_token
      }
    })
    this.$http.post(api + '/qqs.us', jsonValue).then((res) => {
      console.log(res)
      if (res.data.p.isTrue === true) {
        // this.showAlert = true
        // this.alertText = '赚多多将获取您的微信部分信息'
        // this.alertText = '登陆成功'
        window.localStorage.loginP = JSON.stringify(res.data.p)
        window.localStorage.data = JSON.stringify(res.data.p.user)
        localStorage.setItem('token', res.data.p.token)
      } else {
        // this.showAlert = true
        this.alertText = res.data.p.errorMsg
      }
    }, (res) => {
      this.showAlert = true
      this.alertText = '网络错误'
    })
  } else {
    next()
  }

}
